<?php 
namespace Admin\Controller;
use \Think\Controller;

//公共控制器 
class AdminController extends Controller
{
	function __construct(){
		parent::__construct();
		$classes=M("course_list")->where("pid=0")->order("paixu")->select();
		$this->assign("classes",$classes);
	}

	public function _initialize(){
		// dump($_SESSION);
		// exit;
        //判断session是否存在
        if(empty($_SESSION['admin'])){
            //跳转到 登陆页
            $this->redirect();
    	}
    	        //V($_SESSION);

        //权限过滤
        $mname = CONTROLLER_NAME; //获取控制器名
        $aname = ACTION_NAME; //获取方法名

        // echo $mname.'/'.$aname;

        $nodelist = $_SESSION['admin']['nodelist']; //获取权限列表

	        	// dump($nodelist);
	        	// exit;
        //让超级管理员admin拥有所有权限
        if($_SESSION['admin']['user'] != 'admin'){
            //验证操作权限
            if(empty($nodelist[$mname]) || !in_array($aname,$nodelist[$mname])){
                
                $this->error("抱歉！没有操作权限！",U('Index/index'));
                exit;
            }

        }

    }


	



    public function _empty()
    {
        echo '<h1>404</h1>';
    }









}



